package com.ruoyi.performance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.performance.domain.ro.GetListRo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.performance.domain.SillPerformance;
import com.ruoyi.performance.service.ISillPerformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工绩效表Controller
 * 
 * @author ruoyi
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/performance/performance")
public class SillPerformanceController extends BaseController
{
    @Autowired
    private ISillPerformanceService sillPerformanceService;

    /**
     * 查询员工绩效表列表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody GetListRo getListRo)
    {
        startPage();
        List<SillPerformance> list = sillPerformanceService.selectSillPerformanceList(getListRo);
        return getDataTable(list);
    }

    /**
     * 导出员工绩效表列表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:export')")
    @Log(title = "员工绩效表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SillPerformance sillPerformance)
    {
        List<SillPerformance> list = sillPerformanceService.selectSillPerformanceList(sillPerformance);
        ExcelUtil<SillPerformance> util = new ExcelUtil<SillPerformance>(SillPerformance.class);
        util.exportExcel(response, list, "员工绩效表数据");
    }

    /**
     * 获取员工绩效表详细信息
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sillPerformanceService.selectSillPerformanceById(id));
    }

    /**
     * 获取员工单号列表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:query')")
    @GetMapping("/danHao")
    public AjaxResult getDanHao()
    {
        return success(sillPerformanceService.getDanHao());
    }

    /**
     * 获取项目名称
     */
    @GetMapping("/contractName/{sillPerformanceContract}")
    public AjaxResult getContractName(@PathVariable("sillPerformanceContract") String sillPerformanceContract)
    {

        return success(sillPerformanceService.getContractName(sillPerformanceContract));
    }

    /**
     * 新增员工绩效表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:add')")
    @Log(title = "员工绩效表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SillPerformance sillPerformance)
    {
        return toAjax(sillPerformanceService.insertSillPerformance(sillPerformance));
    }

    /**
     * 修改员工绩效表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:edit')")
    @Log(title = "员工绩效表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SillPerformance sillPerformance)
    {
        return toAjax(sillPerformanceService.updateSillPerformance(sillPerformance));
    }

    /**
     * 删除员工绩效表
     */
    @PreAuthorize("@ss.hasPermi('performance:performance:remove')")
    @Log(title = "员工绩效表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sillPerformanceService.deleteSillPerformanceByIds(ids));
    }
}
